package version

import (
	"encoding/json"
	"flag"
	"fmt"
	"os"
)

const (
	Major = 1
	Minor = 0
	Patch = 10
)

// String returns the complete version string
func String() string {
	return fmt.Sprintf("%d.%d.%d", Major, Minor, Patch)
}

type VersionInfo struct {
	Version string `json:"version"`
}

func main() {
	jsonFlag := flag.Bool("json", false, "output version as JSON")
	flag.Parse()

	if *jsonFlag {
		info := VersionInfo{Version: String()}
		json.NewEncoder(os.Stdout).Encode(info)
	} else {
		fmt.Println(String())
	}
}
